---
id: "for"
keywords: ["for", "loop"]
name: "for loop"
summary: "This is the `for` loop."
category: "languageconstructs"
---

ReScript supports `for` loops.

For loops can iterate from a starting value up to (and including) the ending value via the `to` keyword, or in the opposite direction via the `downto` keyword.

### Example

<CodeTab labels={["ReScript", "JS Output"]}>

```res
// Using `to`
for x in 1 to 3 {
  Console.log(x)
}

// Using `downto`
for y in 3 downto 1 {
  Console.log(y)
}
```

```js
for (var x = 1; x <= 3; ++x) {
  console.log(x);
}

for (var y = 3; y >= 1; --y) {
  console.log(y);
}
```

</CodeTab>

### References

- [Control flow](../docs/manual/control-flow.mdx)
